var sign = require('./sign.js');

exports.getProductList = function(req,res){
	sign.dataReq(req,req.session.token,req.body,'product/getProductList','post',function(ResData){
		
		if(ResData!=''){
			res.send(ResData);
		}else{
			res.send('暂时没有数据');
		}
	})
}
exports.getParameter = function(req,res){
	
	sign.dataReq(req,req.session.token,req.body,'product/getParameter','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}
exports.addProductList = function(req,res){
	sign.dataReq(req,req.session.token,req.body,'product/addProductList','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}
exports.addProductType = function(req,res){
	sign.dataReq(req,req.session.token,req.body,'product/addProductType','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}

exports.updateProductList = function(req,res){
	sign.dataReq(req,req.session.token,req.body,'product/updateProductList','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}
exports.updateProductType = function(req,res){
	sign.dataReq(req,req.session.token,req.body,'product/updateProductType','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}

exports.saveParameter = function(req,res){
	 data = req.body;
	var p =JSON.parse(data.parameters);
	  data.parameters = p;
	sign.dataReq(req,req.session.token,data,'product/saveParameter','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}

exports.upload = function(req,res){
	 data = req.body;
	//var p =JSON.parse(data.parameters);
	  //data.parameters = p;
	//sign.dataReq(req,req.session.token,data,'product/upload','post',function(ResData){
	//	if(ResData!=''){
		res.send({"status":200,"massage":"success"});
	//	}
	//})
}


exports.getProductTypeList = function(req,res){
	// sign.dataReq(req,req.session.token,sign.pageData(req.body),'product/getProductTypeList','post',function(ResData){
	sign.dataReq(req,req.session.token,req.body,'product/getProductTypeList','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}else{
			res.send('暂时没有数据');
		}
	})
}

exports.delProductType = function(req,res){
	sign.dataReq(req,req.session.token,req.body,'product/delProductType','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}

exports.delProductConfig = function(req,res){
	sign.dataReq(req,req.session.token,req.body,'product/delProductConfig','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}


exports.productParameter = function(req,res){
	sign.importfileReq(req,req.session.token,req,'product/addProductParameter','post',function(ResData){
		if(ResData!=''){
			res.send(ResData);
		}
	})
}